package com.example.wanbaqian.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.wanbaqian.R;
import com.example.wanbaqian.base.BaseActivity;
import com.example.wanbaqian.base.BaseListener;
import com.example.wanbaqian.utils.HttpUtils;
import com.face.bsdk.util.LogUtils;
import com.joanzapata.pdfview.PDFView;

import java.io.File;

import butterknife.BindView;
import cn.tongdun.android.shell.utils.LogUtil;


public class PDFActivity extends BaseActivity implements BaseListener {


    @BindView(R.id.pdfViews)
    PDFView pdfView;


    private String title = "";
    private String webViewURL = "";

    @Override
    protected int getLayout() {
        return R.layout.activity_pdf;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

        title = getIntent().getExtras().getString("title");

        webViewURL = getIntent().getExtras().getString("url");
        setStatusBarColor(R.color.main_color);
        setToolBar(""+title);


        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


//        webViewURL ="http://qhh-prod.oss-cn-hzfinance.aliyuncs.com/1505921053513_af8ac67a0f228d920bad88ab3faa67d0_quick_sign.pdf";

        if(webViewURL.endsWith(".pdf")){
            HttpUtils.getInstance()
                    .downFile(webViewURL,"xy.pdf",this);

        }
    }

    @Override
    protected void initDate() {

    }

    @Override
    public void downFileSuccess(File file) {
//        Log.e("tag", "downFileSuccess: 文件下载成功？");
        pdfView.fromFile(file)
                .pages(0, 1,2)
                .defaultPage(1)
                .showMinimap(false)
                .enableSwipe(true)
                .load();
    }
}
